

using System;
using System.Data;
using System.IO;
using System.Linq;
using System.Linq.Dynamic;
using System.Linq.Expressions;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Abp.Linq;
using Abp.Linq.Extensions;
using Abp.Extensions;
using Abp.UI;
using Abp.Domain.Repositories;
using Abp.Domain.Services;

using Yozeev;
using Yozeev.BusinessLogic;
using Yozeev.Help;
using Yozeev.SystemConfig;

namespace Yozeev.BusinessLogic.DomainService
{
    /// <summary>
    /// TicketDetailHistory领域层的业务管理
    ///</summary>
    public class TicketDetailHistoryManager : CommonDomainService, ITicketDetailHistoryManager
    {
		
		private readonly IRepository<TicketDetailHistory,Guid> _repository;

		/// <summary>
		/// TicketDetailHistory的构造方法
		///</summary>
		public TicketDetailHistoryManager(
			IRepository<TicketDetailHistory, Guid> repository
			, IRepository<BranchUser, Guid> branchUserRepository
			, IRepository<Customer, Guid> customerRepository
			, IRepository<Ticket, Guid> ticketRepository
			, IRepository<TicketDetail, Guid> ticketDetailRepository
		) : base(branchUserRepository, customerRepository, ticketRepository, ticketDetailRepository)
		{
			_repository =  repository;
		}


		/// <summary>
		/// 初始化
		///</summary>
		public void InitTicketDetailHistory()
		{
			throw new NotImplementedException();
		}

		// TODO:编写领域业务代码



		/// <summary>
		/// 保存验票记录
		/// </summary>
		/// <param name="gateRecord"></param>
		/// <returns></returns>
		public async Task SaveTicketDetailHistory(TicketDetailHistory ticketDetailHistory)
		{
			if(ticketDetailHistory.CreatorUserId!=null)
			{
				var createBranch = GetBranchUser((long)ticketDetailHistory.CreatorUserId);
				CommonHelp.SetBranchId(ticketDetailHistory, createBranch);
			}
			await _repository.InsertAndGetIdAsync(ticketDetailHistory);
		}




	}
}
